package com.dragon.pear.modules.sample.service.assistants.converters;

import java.sql.Timestamp;
import com.dragon.common.base.utils.ConvertUtil;
import com.dragon.common.base.utils.DbUtil;
import com.dragon.common.spring.annotations.DataConverter;
import com.dragon.common.spring.business.base.BaseConverter;
import com.dragon.utils.TimeUtil;
import com.dragon.pear.modules.sample.domain.entity.SmpOrderGoodsEntity;
import com.dragon.pear.modules.sample.web.model.params.create.SmpOrderGoodsCreateParam;
import com.dragon.pear.modules.sample.web.model.params.update.SmpOrderGoodsUpdateParam;
import com.dragon.pear.modules.sample.web.model.results.SmpOrderGoodsResult;

/**
 * @author Chris Chan
 * Create on 2025-10-15 17:59
 * Use for: 订单商品 业务数据转换助手
 * Explain:
 * 
 */
@DataConverter
public class SmpOrderGoodsConverter implements BaseConverter<
        SmpOrderGoodsEntity,
        SmpOrderGoodsCreateParam,
        SmpOrderGoodsUpdateParam,
        SmpOrderGoodsResult> {
    @Override
    public SmpOrderGoodsEntity fromParam(SmpOrderGoodsCreateParam param) {
        SmpOrderGoodsEntity entity = new SmpOrderGoodsEntity();
        ConvertUtil.copyProperties(param, entity, "id");
        // 生成编码
        entity.setCode(DbUtil.buildCode());
        return entity;
    }

    @Override
    public SmpOrderGoodsEntity fromUpdateParam(SmpOrderGoodsUpdateParam param) {
        SmpOrderGoodsEntity entity = ConvertUtil.convert(param, SmpOrderGoodsEntity.class);
        return entity;
    }

    @Override
    public SmpOrderGoodsResult toResult(SmpOrderGoodsEntity entity) {
        SmpOrderGoodsResult result = ConvertUtil.convert(entity,SmpOrderGoodsResult.class);
        return result;
    }
}